from monitor import load_prev_data
from datetime import datetime
import tushare as ts
import pandas as pd
from utils import read_config,get_directory
import os
from stock.trend_calculate import check_stock_conditions


config = read_config()
_base_directory = config.get('settings','base_file')
_daily_directory = config.get('settings','monitor_file')
monitor_daily_directory = get_directory(_base_directory,_daily_directory)

print('start monitor big')
# df = load_prev_data.load_data(datetime.fromisoformat('2024-03-22'))
df = load_prev_data.load_data()
rs_array =[]
# 对DataFrame按'code'分组，并应用筛选条件
filtered_groups = df.groupby('ts_code',group_keys=False)
for row in filtered_groups:
    _code = row[0]
    print('start',_code)
    _rs_bool,_rs_message = check_stock_conditions(df[df['ts_code'] == _code])
    if _rs_bool:
        rs_array.append([row[0],_rs_message])

# 打印结果
print(rs_array)